import { Search } from "@taroify/icons";
import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import MyInput from "./MyInput";

export default ({
  change,
  confirm,
  act = false,
  placeholder = "搜吧、搜贴、搜人",
}: {
  change?: (v: string) => void;
  confirm?: () => void;
  act?: boolean;
  placeholder?: string;
}) => {
  function handleFocus() {
    act && Taro.navigateTo({ url: "/pages/index/search" });
  }
  return (
    <View className="flex gap-1 w-full items-center">
      <MyInput
        onFocus={() => handleFocus()}
        left={<Search />}
        shape="circle"
        padding="4px 18px"
        placeholder={placeholder}
        change={change}
        onConfirm={confirm}
      />
    </View>
  );
};
